package com.example.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Admission;



@Repository()
public interface Admission_Mapper extends BaseMapper<Admission>{
	
	@Select("select admission.*,patient.name patient_name,department.name department_name "
			+ " from admission inner join patient on admission.patient_id=patient.id "
			+ " inner join department on admission.department_id=department.id "
			+"${where} ${limitstr}")
	public List<Admission> select(SearchInfo info);
	@Select("select count(1) from admission inner join patient on admission.patient_id=patient.id "
			+ " inner join department on admission.department_id=department.id "
			+"  ${where} ")
	public long selectCount(SearchInfo info);
	
	@Insert("insert into admission (patient_id,admission_date,department_id) values(#{patient_id},#{admission_date},#{department_id})")
	public void insert (Admission u);
	
	@Update("update admission set patient_id=#{patient_id},admission_date=#{admission_date},department_id=#{department_id} where id=#{id}")
	public void update (Admission u);
	
	
	@Select("delete from admission where id=#{id}")
	public void delete(int id);
	
	@Select("select * from admission where id=#{id} ")
	public Admission selectById(int id);
	
}
